package com.auxgroup.hr.front.service.process.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.stereotype.Service;

import com.auxgroup.hr.front.dao.domain.PsCWfAptEdu;
import com.auxgroup.hr.front.dao.domain.PsCWfAptWork;
import com.auxgroup.hr.front.dao.domain.PsCWfDrftHdr;
import com.auxgroup.hr.front.dao.repository.PsCWfAptEduRepository;
import com.auxgroup.hr.front.dao.repository.PsCWfAptWorkRepository;
import com.auxgroup.hr.front.dao.repository.PsCWfDrftHdrRepository;
import com.auxgroup.hr.front.service.process.WfDrftHdrService;

/** 
 * @author lvliuhao 
 * @version 创建时间：2018年7月11日 下午4:34:30 
 * 类说明 
 */
@Service("wfDrftHdrService")
public class WfDrftHdrServiceImpl implements WfDrftHdrService {
	
	@Autowired
	private PsCWfDrftHdrRepository psCWfDrftHdrRepository;
	
	@Autowired
	private PsCWfAptEduRepository psCWfAptEduRepository;
	
	@Autowired
	private PsCWfAptWorkRepository psCWfAptWorkRepository;

	
	public PsCWfDrftHdr getDrftHdr(String transNum) {
		return psCWfDrftHdrRepository.findOne(transNum);
	}

	
	public void saveDrftHdr(PsCWfDrftHdr drftHdr) {
		psCWfDrftHdrRepository.save(drftHdr);
	}

	public List<PsCWfAptEdu> getEduList(String transNum) {
		PsCWfAptEdu aptEdu = new PsCWfAptEdu();
		aptEdu.setcTransactionNbr(transNum);
		return psCWfAptEduRepository.findAll(Example.of(aptEdu),new Sort(Direction.DESC, "startDate"));
	}

	public List<PsCWfAptWork> getWorkList(String transNum) {
		PsCWfAptWork aptWork = new PsCWfAptWork();
		aptWork.setcTransactionNbr(transNum);
		return psCWfAptWorkRepository.findAll(Example.of(aptWork),new Sort(Direction.DESC, "startDate"));
	}

}
 